﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gems.Console
{
    internal class Configuration : IConfiguration
    {
        string[] _hosts = new[] { "l33t", "ihvol", "ihvow" };

        public string HostName
        {
            get { return System.Environment.MachineName.ToLowerInvariant(); }
        }

        public int GossipInterval
        {
            get { return 100; }
        }

        public int GossipTimeout
        {
            get { return 5; }
        }

        public int UpdateTimeout
        {
            get { return 50; }
        }

        public string[] Hosts
        {
            get { return _hosts; }
        }

        public int HostPosition
        {
            get { return GetIndex(_hosts, HostName); }
        }

        public int GossipPort
        {
            get { return 6878; }
        }

        private static int GetIndex<T>(T[] array, T item)
        {
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].Equals(item)) return i;
            }

            throw new ArgumentException();
        }
    }
}
